<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
import Add from "./../add/index";
import See from "./../see/index";

import TeamMember from "./../teamMember/index";

export default {
  mixins: [
    Vue.prototype.$vFN.Mixins.Base,
    Vue.prototype.$vFN.Mixins.Page,
    Vue.prototype.$vFN.Mixins.Table,
  ],
  components: {
    ImageBox: async () =>
      Vue.extend(await Vue.prototype.$vFN.Components.Base.ImageBox()),
  },
  data() {
    return {
      appWindow: window,
      // 页面接口地址
      apiUrl: {
        list: "plugin/team-dividend/admin/member/list",
        delete: "plugin/team-dividend/admin/member/destroy",
      },
      // 表格查询数据
      mixinTable_tableSearchData: {},
   
      // 表格数据删除展示结构
      tableDeleteConfig: {
        columns: [
          {
            label: "名称",
            prop: "member.nickName",
          },
          {
            label: "手机好",
            prop: "member.mobile",
          },
        ],
      },
      // 表格数据类型
      mixinTable_tableDataType: "tree",
    };
  },
  methods: {
    // 新增
    addCaptain() {
      Add.init({
        onSuccess: () => {
          this.mixinTable_refreshData()
        }
      })
    },
    // 查看
    see(_memberId) {
      See.init({
        memberId: _memberId,
        onSuccess: () => {
          this.mixinTable_refreshData()
        }
      })
    },

    // 禁用/启用
    async enable(_memberId, _activeId) {
      this.$confirm("确定进行此操作吗？", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        // type: "error",
        dangerouslyUseHTMLString: true,
      }).then(async () => {
          let res = await this.$vFN.Http.post({
            url: "plugin/team-dividend/admin/member/setDealerActive",
            data: {
              member_id: _memberId,
              active: _activeId == 0 ? 1 : 0,
            }
          }, window);
          this.mixinTable_refreshData();
          if (res.code == 200) {
            this.$vFN.Tools.messageSuccess("操作成功");
          }
        }).catch(() => {});
    },
    
    // 打开添加/修改
    async editBoxOpen(params_) {
      TeamMember.init({
        mixinEdit_parent: this,
        // mixinEdit_editType: params_.type,
        id: params_.id,
        subData: params_.data,
      });
    },
    // 初始化
    async init() {
      this.mixinTable_refreshData();
    },
  },
  mounted() {
    this.init();
  },
  activated() {},
};
</script>